Skip to content

[Obs AI Assistant] Disallow destructive actions via the Elasticsearch tool#229497

Merged
viduni94 merged 6 commits intoelastic:mainfrom
viduni94:disallow-destructive-actions-elasticsearch-tool
Jul 28, 2025
Merged

[Obs AI Assistant] Disallow destructive actions via the Elasticsearch tool#229497
viduni94 merged 6 commits intoelastic:mainfrom
viduni94:disallow-destructive-actions-elasticsearch-tool

Conversation

@viduni94
Copy link
Copy Markdown
Contributor

@viduni94 viduni94 commented Jul 25, 2025

Closes #229501

Summary

Problem

There have been several reports that the AI Assistant goes rogue and performs destructive actions.

Solution

  • Instruct the LLM to not perform destructive actions and to mention to the user that these actions can't be performed
  • Only allow GET requests and GET/POST requests to the /_search endpoint when executing the Elasticsearch tool
  • If the LLM attempts to call disallowed methods, throw an error

The evaluation framework scenarios which expected deletion of an index was updated to conform to the above changes as well.

What's not included

  • Guardrails for the query tool and kibana tool
  • Allowing destructive actions via a button click to "Confirm"

Checklist

  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines
  • Review the backport guidelines and apply applicable backport:* labels.

@viduni94 viduni94 self-assigned this Jul 25, 2025
@viduni94 viduni94 requested a review from a team as a code owner July 25, 2025 17:05
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/obs-ai-assistant (Team:Obs AI Assistant)

@botelastic botelastic bot added the ci:project-deploy-observability Create an Observability project label Jul 25, 2025
@github-actions
Copy link
Copy Markdown
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

const isSearchEndpoint = lastPathSegment === '_search';

if (method !== 'GET' && !(method === 'POST' && isSearchEndpoint)) {
throw new Error(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the enum of allowed methods, I left PUT, PATCH, DELETE as it is.

How it works:

  • If the LLM calls the Elasticsearch API with PUT, it won't fail tool call validations as it's an allowed method, but it will throw an error during query execution, so that the LLM knows that this method is not allowed.

The reason to leave those methods in the allowed list is because:

  • When I removed them and only allowed POST and GET in the allowed methods enums, no matter what instruction we give to some LLMs, the model tries to call the Elasticsearch tool with a disallowed method such as PUT and it gets caught to tool validations and throws an error - Invalid tool arguments (this is mostly observed with Claude)
  • While it works as expected, this disrupts the conversation flow for the user with an error. Therefore, instead of blocking it at the tool call arguments, if a model decides to call the Elasticsearch tool with PUT, DELETE, PATCH or POST to non-search endpoint, we throw an error here and it goes in the normal correct conversation flow by informing the user that this method is not allowed to be performed by the assistant.

Example:

image

Trace - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/589c42bb6c013c53a3b56a49021f442f?selectedSpanNodeId=U3BhbjozNzU5NjI%3D

@viduni94 viduni94 requested a review from sorenlouv July 28, 2025 15:51
@elasticmachine
Copy link
Copy Markdown
Contributor

elasticmachine commented Jul 28, 2025

💚 Build Succeeded

  • Buildkite Build
  • Commit: 0f861f3
  • Kibana Serverless Image: docker.elastic.co/kibana-ci/kibana-serverless:pr-229497-0f861f340183

Metrics [docs]

✅ unchanged

History

cc @viduni94

@viduni94 viduni94 merged commit 808bac6 into elastic:main Jul 28, 2025
12 checks passed
@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 8.18, 8.19, 9.0, 9.1

https://github.com/elastic/kibana/actions/runs/16582110376

@viduni94 viduni94 removed the v9.0.5 label Jul 29, 2025
@viduni94 viduni94 removed the v8.18.5 label Jul 29, 2025
@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 8.18, 8.19, 9.0, 9.1

https://github.com/elastic/kibana/actions/runs/16582110376

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jul 29, 2025
… tool (elastic#229497)

Closes elastic#229501

## Summary

### Problem
There have been several reports that the AI Assistant goes rogue and
performs destructive actions.

### Solution
- Instruct the LLM to not perform destructive actions and to mention to
the user that these actions can't be performed
- Only allow `GET` requests and `GET`/`POST` requests to the `/_search`
endpoint when executing the Elasticsearch tool
- If the LLM attempts to call disallowed methods, throw an error

The evaluation framework scenarios which expected deletion of an index
was updated to conform to the above changes as well.

### What's not included
- Guardrails for the `query` tool and `kibana` tool
- Allowing destructive actions via a button click to "Confirm"

### Checklist

- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- [x] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

(cherry picked from commit 808bac6)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jul 29, 2025
… tool (elastic#229497)

Closes elastic#229501

## Summary

### Problem
There have been several reports that the AI Assistant goes rogue and
performs destructive actions.

### Solution
- Instruct the LLM to not perform destructive actions and to mention to
the user that these actions can't be performed
- Only allow `GET` requests and `GET`/`POST` requests to the `/_search`
endpoint when executing the Elasticsearch tool
- If the LLM attempts to call disallowed methods, throw an error

The evaluation framework scenarios which expected deletion of an index
was updated to conform to the above changes as well.

### What's not included
- Guardrails for the `query` tool and `kibana` tool
- Allowing destructive actions via a button click to "Confirm"

### Checklist

- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- [x] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

(cherry picked from commit 808bac6)
@kibanamachine
Copy link
Copy Markdown
Contributor

💔 Some backports could not be created

Status Branch Result
8.18 Backport failed because of merge conflicts
8.19 Backport failed because of merge conflicts
9.0
9.1

Note: Successful backport PRs will be merged automatically after passing CI.

Manual backport

To create the backport manually run:

node scripts/backport --pr 229497

Questions ?

Please refer to the Backport tool documentation

@viduni94
Copy link
Copy Markdown
Contributor Author

💚 All backports created successfully

Status Branch Result
8.19
8.18

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

viduni94 added a commit to viduni94/kibana that referenced this pull request Jul 29, 2025
… tool (elastic#229497)

Closes elastic#229501

## Summary

### Problem
There have been several reports that the AI Assistant goes rogue and
performs destructive actions.

### Solution
- Instruct the LLM to not perform destructive actions and to mention to
the user that these actions can't be performed
- Only allow `GET` requests and `GET`/`POST` requests to the `/_search`
endpoint when executing the Elasticsearch tool
- If the LLM attempts to call disallowed methods, throw an error

The evaluation framework scenarios which expected deletion of an index
was updated to conform to the above changes as well.

### What's not included
- Guardrails for the `query` tool and `kibana` tool
- Allowing destructive actions via a button click to "Confirm"

### Checklist

- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- [x] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

(cherry picked from commit 808bac6)

# Conflicts:
#	x-pack/solutions/observability/plugins/observability_ai_assistant_app/scripts/evaluation/scenarios/elasticsearch/index.spec.ts
viduni94 added a commit to viduni94/kibana that referenced this pull request Jul 29, 2025
… tool (elastic#229497)

Closes elastic#229501

## Summary

### Problem
There have been several reports that the AI Assistant goes rogue and
performs destructive actions.

### Solution
- Instruct the LLM to not perform destructive actions and to mention to
the user that these actions can't be performed
- Only allow `GET` requests and `GET`/`POST` requests to the `/_search`
endpoint when executing the Elasticsearch tool
- If the LLM attempts to call disallowed methods, throw an error

The evaluation framework scenarios which expected deletion of an index
was updated to conform to the above changes as well.

### What's not included
- Guardrails for the `query` tool and `kibana` tool
- Allowing destructive actions via a button click to "Confirm"

### Checklist

- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- [x] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

(cherry picked from commit 808bac6)

# Conflicts:
#	x-pack/solutions/observability/plugins/observability_ai_assistant_app/scripts/evaluation/scenarios/elasticsearch/index.spec.ts
viduni94 added a commit that referenced this pull request Jul 29, 2025
…search tool (#229497) (#229810)

# Backport

This will backport the following commits from `main` to `9.0`:
- [[Obs AI Assistant] Disallow destructive actions via the Elasticsearch
tool (#229497)](#229497)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Viduni
Wickramarachchi","email":"viduni.wickramarachchi@elastic.co"},"sourceCommit":{"committedDate":"2025-07-28T22:52:20Z","message":"[Obs
AI Assistant] Disallow destructive actions via the Elasticsearch tool
(#229497)\n\nCloses
https://github.com/elastic/kibana/issues/229501\n\n## Summary\n\n###
Problem\nThere have been several reports that the AI Assistant goes
rogue and\nperforms destructive actions.\n\n### Solution\n- Instruct the
LLM to not perform destructive actions and to mention to\nthe user that
these actions can't be performed\n- Only allow `GET` requests and
`GET`/`POST` requests to the `/_search`\nendpoint when executing the
Elasticsearch tool\n- If the LLM attempts to call disallowed methods,
throw an error\n\nThe evaluation framework scenarios which expected
deletion of an index\nwas updated to conform to the above changes as
well.\n\n### What's not included\n- Guardrails for the `query` tool and
`kibana` tool\n- Allowing destructive actions via a button click to
\"Confirm\"\n\n### Checklist\n\n- [x] The PR description includes the
appropriate Release Notes section,\nand the correct `release_note:*`
label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*`
labels.","sha":"808bac66e62492547326aaefc812e2b743f50e9b","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Obs
AI
Assistant","ci:project-deploy-observability","backport:version","v9.2.0","v9.1.1","v8.19.1"],"title":"[Obs
AI Assistant] Disallow destructive actions via the Elasticsearch
tool","number":229497,"url":"https://github.com/elastic/kibana/pull/229497","mergeCommit":{"message":"[Obs
AI Assistant] Disallow destructive actions via the Elasticsearch tool
(#229497)\n\nCloses
https://github.com/elastic/kibana/issues/229501\n\n## Summary\n\n###
Problem\nThere have been several reports that the AI Assistant goes
rogue and\nperforms destructive actions.\n\n### Solution\n- Instruct the
LLM to not perform destructive actions and to mention to\nthe user that
these actions can't be performed\n- Only allow `GET` requests and
`GET`/`POST` requests to the `/_search`\nendpoint when executing the
Elasticsearch tool\n- If the LLM attempts to call disallowed methods,
throw an error\n\nThe evaluation framework scenarios which expected
deletion of an index\nwas updated to conform to the above changes as
well.\n\n### What's not included\n- Guardrails for the `query` tool and
`kibana` tool\n- Allowing destructive actions via a button click to
\"Confirm\"\n\n### Checklist\n\n- [x] The PR description includes the
appropriate Release Notes section,\nand the correct `release_note:*`
label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*`
labels.","sha":"808bac66e62492547326aaefc812e2b743f50e9b"}},"sourceBranch":"main","suggestedTargetBranches":["9.1","8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/229497","number":229497,"mergeCommit":{"message":"[Obs
AI Assistant] Disallow destructive actions via the Elasticsearch tool
(#229497)\n\nCloses
https://github.com/elastic/kibana/issues/229501\n\n## Summary\n\n###
Problem\nThere have been several reports that the AI Assistant goes
rogue and\nperforms destructive actions.\n\n### Solution\n- Instruct the
LLM to not perform destructive actions and to mention to\nthe user that
these actions can't be performed\n- Only allow `GET` requests and
`GET`/`POST` requests to the `/_search`\nendpoint when executing the
Elasticsearch tool\n- If the LLM attempts to call disallowed methods,
throw an error\n\nThe evaluation framework scenarios which expected
deletion of an index\nwas updated to conform to the above changes as
well.\n\n### What's not included\n- Guardrails for the `query` tool and
`kibana` tool\n- Allowing destructive actions via a button click to
\"Confirm\"\n\n### Checklist\n\n- [x] The PR description includes the
appropriate Release Notes section,\nand the correct `release_note:*`
label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*`
labels.","sha":"808bac66e62492547326aaefc812e2b743f50e9b"}},{"branch":"9.1","label":"v9.1.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Viduni Wickramarachchi <viduni.wickramarachchi@elastic.co>
viduni94 added a commit that referenced this pull request Jul 29, 2025
…search tool (#229497) (#229811)

# Backport

This will backport the following commits from `main` to `9.1`:
- [[Obs AI Assistant] Disallow destructive actions via the Elasticsearch
tool (#229497)](#229497)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Viduni
Wickramarachchi","email":"viduni.wickramarachchi@elastic.co"},"sourceCommit":{"committedDate":"2025-07-28T22:52:20Z","message":"[Obs
AI Assistant] Disallow destructive actions via the Elasticsearch tool
(#229497)\n\nCloses
https://github.com/elastic/kibana/issues/229501\n\n## Summary\n\n###
Problem\nThere have been several reports that the AI Assistant goes
rogue and\nperforms destructive actions.\n\n### Solution\n- Instruct the
LLM to not perform destructive actions and to mention to\nthe user that
these actions can't be performed\n- Only allow `GET` requests and
`GET`/`POST` requests to the `/_search`\nendpoint when executing the
Elasticsearch tool\n- If the LLM attempts to call disallowed methods,
throw an error\n\nThe evaluation framework scenarios which expected
deletion of an index\nwas updated to conform to the above changes as
well.\n\n### What's not included\n- Guardrails for the `query` tool and
`kibana` tool\n- Allowing destructive actions via a button click to
\"Confirm\"\n\n### Checklist\n\n- [x] The PR description includes the
appropriate Release Notes section,\nand the correct `release_note:*`
label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*`
labels.","sha":"808bac66e62492547326aaefc812e2b743f50e9b","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Obs
AI
Assistant","ci:project-deploy-observability","backport:version","v9.2.0","v9.1.1","v8.19.1"],"title":"[Obs
AI Assistant] Disallow destructive actions via the Elasticsearch
tool","number":229497,"url":"https://github.com/elastic/kibana/pull/229497","mergeCommit":{"message":"[Obs
AI Assistant] Disallow destructive actions via the Elasticsearch tool
(#229497)\n\nCloses
https://github.com/elastic/kibana/issues/229501\n\n## Summary\n\n###
Problem\nThere have been several reports that the AI Assistant goes
rogue and\nperforms destructive actions.\n\n### Solution\n- Instruct the
LLM to not perform destructive actions and to mention to\nthe user that
these actions can't be performed\n- Only allow `GET` requests and
`GET`/`POST` requests to the `/_search`\nendpoint when executing the
Elasticsearch tool\n- If the LLM attempts to call disallowed methods,
throw an error\n\nThe evaluation framework scenarios which expected
deletion of an index\nwas updated to conform to the above changes as
well.\n\n### What's not included\n- Guardrails for the `query` tool and
`kibana` tool\n- Allowing destructive actions via a button click to
\"Confirm\"\n\n### Checklist\n\n- [x] The PR description includes the
appropriate Release Notes section,\nand the correct `release_note:*`
label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*`
labels.","sha":"808bac66e62492547326aaefc812e2b743f50e9b"}},"sourceBranch":"main","suggestedTargetBranches":["9.1","8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/229497","number":229497,"mergeCommit":{"message":"[Obs
AI Assistant] Disallow destructive actions via the Elasticsearch tool
(#229497)\n\nCloses
https://github.com/elastic/kibana/issues/229501\n\n## Summary\n\n###
Problem\nThere have been several reports that the AI Assistant goes
rogue and\nperforms destructive actions.\n\n### Solution\n- Instruct the
LLM to not perform destructive actions and to mention to\nthe user that
these actions can't be performed\n- Only allow `GET` requests and
`GET`/`POST` requests to the `/_search`\nendpoint when executing the
Elasticsearch tool\n- If the LLM attempts to call disallowed methods,
throw an error\n\nThe evaluation framework scenarios which expected
deletion of an index\nwas updated to conform to the above changes as
well.\n\n### What's not included\n- Guardrails for the `query` tool and
`kibana` tool\n- Allowing destructive actions via a button click to
\"Confirm\"\n\n### Checklist\n\n- [x] The PR description includes the
appropriate Release Notes section,\nand the correct `release_note:*`
label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*`
labels.","sha":"808bac66e62492547326aaefc812e2b743f50e9b"}},{"branch":"9.1","label":"v9.1.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Viduni Wickramarachchi <viduni.wickramarachchi@elastic.co>
viduni94 added a commit that referenced this pull request Jul 29, 2025
…csearch tool (#229497) (#229817)

# Backport

This will backport the following commits from `main` to `8.18`:
- [[Obs AI Assistant] Disallow destructive actions via the Elasticsearch
tool (#229497)](#229497)

<!--- Backport version: 10.0.1 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Viduni
Wickramarachchi","email":"viduni.wickramarachchi@elastic.co"},"sourceCommit":{"committedDate":"2025-07-28T22:52:20Z","message":"[Obs
AI Assistant] Disallow destructive actions via the Elasticsearch tool
(#229497)\n\nCloses
https://github.com/elastic/kibana/issues/229501\n\n## Summary\n\n###
Problem\nThere have been several reports that the AI Assistant goes
rogue and\nperforms destructive actions.\n\n### Solution\n- Instruct the
LLM to not perform destructive actions and to mention to\nthe user that
these actions can't be performed\n- Only allow `GET` requests and
`GET`/`POST` requests to the `/_search`\nendpoint when executing the
Elasticsearch tool\n- If the LLM attempts to call disallowed methods,
throw an error\n\nThe evaluation framework scenarios which expected
deletion of an index\nwas updated to conform to the above changes as
well.\n\n### What's not included\n- Guardrails for the `query` tool and
`kibana` tool\n- Allowing destructive actions via a button click to
\"Confirm\"\n\n### Checklist\n\n- [x] The PR description includes the
appropriate Release Notes section,\nand the correct `release_note:*`
label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*`
labels.","sha":"808bac66e62492547326aaefc812e2b743f50e9b","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Obs
AI
Assistant","ci:project-deploy-observability","backport:version","v9.2.0","v9.1.1","v8.19.1"],"title":"[Obs
AI Assistant] Disallow destructive actions via the Elasticsearch
tool","number":229497,"url":"https://github.com/elastic/kibana/pull/229497","mergeCommit":{"message":"[Obs
AI Assistant] Disallow destructive actions via the Elasticsearch tool
(#229497)\n\nCloses
https://github.com/elastic/kibana/issues/229501\n\n## Summary\n\n###
Problem\nThere have been several reports that the AI Assistant goes
rogue and\nperforms destructive actions.\n\n### Solution\n- Instruct the
LLM to not perform destructive actions and to mention to\nthe user that
these actions can't be performed\n- Only allow `GET` requests and
`GET`/`POST` requests to the `/_search`\nendpoint when executing the
Elasticsearch tool\n- If the LLM attempts to call disallowed methods,
throw an error\n\nThe evaluation framework scenarios which expected
deletion of an index\nwas updated to conform to the above changes as
well.\n\n### What's not included\n- Guardrails for the `query` tool and
`kibana` tool\n- Allowing destructive actions via a button click to
\"Confirm\"\n\n### Checklist\n\n- [x] The PR description includes the
appropriate Release Notes section,\nand the correct `release_note:*`
label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*`
labels.","sha":"808bac66e62492547326aaefc812e2b743f50e9b"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/229497","number":229497,"mergeCommit":{"message":"[Obs
AI Assistant] Disallow destructive actions via the Elasticsearch tool
(#229497)\n\nCloses
https://github.com/elastic/kibana/issues/229501\n\n## Summary\n\n###
Problem\nThere have been several reports that the AI Assistant goes
rogue and\nperforms destructive actions.\n\n### Solution\n- Instruct the
LLM to not perform destructive actions and to mention to\nthe user that
these actions can't be performed\n- Only allow `GET` requests and
`GET`/`POST` requests to the `/_search`\nendpoint when executing the
Elasticsearch tool\n- If the LLM attempts to call disallowed methods,
throw an error\n\nThe evaluation framework scenarios which expected
deletion of an index\nwas updated to conform to the above changes as
well.\n\n### What's not included\n- Guardrails for the `query` tool and
`kibana` tool\n- Allowing destructive actions via a button click to
\"Confirm\"\n\n### Checklist\n\n- [x] The PR description includes the
appropriate Release Notes section,\nand the correct `release_note:*`
label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*`
labels.","sha":"808bac66e62492547326aaefc812e2b743f50e9b"}},{"branch":"9.1","label":"v9.1.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/229811","number":229811,"state":"OPEN"},{"branch":"8.19","label":"v8.19.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"url":"https://github.com/elastic/kibana/pull/229810","number":229810,"branch":"9.0","state":"OPEN"}]}]
BACKPORT-->
viduni94 added a commit that referenced this pull request Jul 29, 2025
…csearch tool (#229497) (#229816)

# Backport

This will backport the following commits from `main` to `8.19`:
- [[Obs AI Assistant] Disallow destructive actions via the Elasticsearch
tool (#229497)](#229497)

<!--- Backport version: 10.0.1 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Viduni
Wickramarachchi","email":"viduni.wickramarachchi@elastic.co"},"sourceCommit":{"committedDate":"2025-07-28T22:52:20Z","message":"[Obs
AI Assistant] Disallow destructive actions via the Elasticsearch tool
(#229497)\n\nCloses
https://github.com/elastic/kibana/issues/229501\n\n## Summary\n\n###
Problem\nThere have been several reports that the AI Assistant goes
rogue and\nperforms destructive actions.\n\n### Solution\n- Instruct the
LLM to not perform destructive actions and to mention to\nthe user that
these actions can't be performed\n- Only allow `GET` requests and
`GET`/`POST` requests to the `/_search`\nendpoint when executing the
Elasticsearch tool\n- If the LLM attempts to call disallowed methods,
throw an error\n\nThe evaluation framework scenarios which expected
deletion of an index\nwas updated to conform to the above changes as
well.\n\n### What's not included\n- Guardrails for the `query` tool and
`kibana` tool\n- Allowing destructive actions via a button click to
\"Confirm\"\n\n### Checklist\n\n- [x] The PR description includes the
appropriate Release Notes section,\nand the correct `release_note:*`
label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*`
labels.","sha":"808bac66e62492547326aaefc812e2b743f50e9b","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Obs
AI
Assistant","ci:project-deploy-observability","backport:version","v9.2.0","v9.1.1","v8.19.1"],"title":"[Obs
AI Assistant] Disallow destructive actions via the Elasticsearch
tool","number":229497,"url":"https://github.com/elastic/kibana/pull/229497","mergeCommit":{"message":"[Obs
AI Assistant] Disallow destructive actions via the Elasticsearch tool
(#229497)\n\nCloses
https://github.com/elastic/kibana/issues/229501\n\n## Summary\n\n###
Problem\nThere have been several reports that the AI Assistant goes
rogue and\nperforms destructive actions.\n\n### Solution\n- Instruct the
LLM to not perform destructive actions and to mention to\nthe user that
these actions can't be performed\n- Only allow `GET` requests and
`GET`/`POST` requests to the `/_search`\nendpoint when executing the
Elasticsearch tool\n- If the LLM attempts to call disallowed methods,
throw an error\n\nThe evaluation framework scenarios which expected
deletion of an index\nwas updated to conform to the above changes as
well.\n\n### What's not included\n- Guardrails for the `query` tool and
`kibana` tool\n- Allowing destructive actions via a button click to
\"Confirm\"\n\n### Checklist\n\n- [x] The PR description includes the
appropriate Release Notes section,\nand the correct `release_note:*`
label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*`
labels.","sha":"808bac66e62492547326aaefc812e2b743f50e9b"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/229497","number":229497,"mergeCommit":{"message":"[Obs
AI Assistant] Disallow destructive actions via the Elasticsearch tool
(#229497)\n\nCloses
https://github.com/elastic/kibana/issues/229501\n\n## Summary\n\n###
Problem\nThere have been several reports that the AI Assistant goes
rogue and\nperforms destructive actions.\n\n### Solution\n- Instruct the
LLM to not perform destructive actions and to mention to\nthe user that
these actions can't be performed\n- Only allow `GET` requests and
`GET`/`POST` requests to the `/_search`\nendpoint when executing the
Elasticsearch tool\n- If the LLM attempts to call disallowed methods,
throw an error\n\nThe evaluation framework scenarios which expected
deletion of an index\nwas updated to conform to the above changes as
well.\n\n### What's not included\n- Guardrails for the `query` tool and
`kibana` tool\n- Allowing destructive actions via a button click to
\"Confirm\"\n\n### Checklist\n\n- [x] The PR description includes the
appropriate Release Notes section,\nand the correct `release_note:*`
label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*`
labels.","sha":"808bac66e62492547326aaefc812e2b743f50e9b"}},{"branch":"9.1","label":"v9.1.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/229811","number":229811,"state":"OPEN"},{"branch":"8.19","label":"v8.19.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"url":"https://github.com/elastic/kibana/pull/229810","number":229810,"branch":"9.0","state":"OPEN"}]}]
BACKPORT-->
@mistic mistic removed the v9.1.0 label Jul 29, 2025
Comment on lines +56 to +61
const [pathWithoutQuery] = path.split('?');
const pathSegments = pathWithoutQuery.replace(/^\//, '').split('/');
const lastPathSegment = pathSegments[pathSegments.length - 1];
const isSearchEndpoint = lastPathSegment === '_search';

if (method !== 'GET' && !(method === 'POST' && isSearchEndpoint)) {
Copy link
Copy Markdown
Contributor

@sorenlouv sorenlouv Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you extract this to a well-named helper (eg isOperationAllowed) to contain this logic?

Copy link
Copy Markdown
Contributor

@sorenlouv sorenlouv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have a test (API test is probably a good fit) to ensure that only certain operations are allowed. You can use the LLM proxy to validate that any attempts by the LLM to perform mutating operations using the elasticsearch tool will be rejected

delanni pushed a commit to delanni/kibana that referenced this pull request Aug 5, 2025
… tool (elastic#229497)

Closes elastic#229501

## Summary

### Problem
There have been several reports that the AI Assistant goes rogue and
performs destructive actions.

### Solution
- Instruct the LLM to not perform destructive actions and to mention to
the user that these actions can't be performed
- Only allow `GET` requests and `GET`/`POST` requests to the `/_search`
endpoint when executing the Elasticsearch tool
- If the LLM attempts to call disallowed methods, throw an error

The evaluation framework scenarios which expected deletion of an index
was updated to conform to the above changes as well.

### What's not included
- Guardrails for the `query` tool and `kibana` tool
- Allowing destructive actions via a button click to "Confirm"

### Checklist

- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- [x] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Obs AI Assistant] Disallow destructive actions via the Elasticsearch tool

6 participants